|
|
|
|
|
|
|
api32.txt advocate a more complex approachrequiring you to obtain the address of a DEVMODE structure and pass the pointer explicitly? |
|
|
|
|
|
|
|
|
Was it a careless oversight on my part? |
|
|
|
|
|
|
|
|
Or is it just barely possible that the declaration in the win32api.txt file is wrongso wrong that using the declaration might lead to memory exceptions? Not just memory exceptions, but exceptions that are intermittent depending on the system configuration in use? |
|
|
|
|
|
|
|
|
And if the latter, can you explain why? |
|
|
|
|
|
|
|
|
The DocProp sample project uses the declaration from win32api.txt to show the printer setup dialog box for the current printer, then displays whether you have selected portrait or landscape mode for the printer. The code that actually performs the operation is as follows (declarations and constants are omitted from this listing): |
|
|
|
|
|
|
|
|
Dim hPrinter&
Dim res&
Dim dmIn As DEVMODE
Dim dmOut As DEVMODE
' Non-zero on success
res = OpenPrinter(Printer.DeviceName, hPrinter, 0)
If res = 0 Then
lblStatus.Caption = "Printer could not be opened"
Exit Sub
End If
res = DocumentProperties(hwnd, hPrinter, Printer.DeviceName, _
dmOut, dmIn, DM_OUT_BUFFER Or DM_IN_PROMPT)
If dmOut.dmOrientation = DMORIENT_LANDSCAPE Then
lblStatus.Caption = "Printer is in landscape mode"
Else
lblStatus.Caption = "Printer is in portrait mode"
End If
' You can modify the contents of the dmout buffer, then
' call DocumentProperties with DM_IN_BUFFER to set the new values
Call ClosePrinter(hPrinter) |
|
|
|
|
|